package com.ryan.mdp.client.collection;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;

import com.ryan.mdp.api.collection.CollectionDemoService;
import com.ryan.mdp.dto.DemoDto;

@ContextConfiguration(locations = { "classpath:/context/context-mdp-client.xml" })
public class CollectionDemoClient extends AbstractJUnit4SpringContextTests {

    @Autowired
    private CollectionDemoService demo;

    @Test
    public void testSyncArray() {
        DemoDto dto1 = new DemoDto("tom", 123);
        DemoDto dto2 = new DemoDto("peter", 4546);
        demo.syncArray(new DemoDto[] { dto1, dto2 });
    }

    @Test
    public void testSyncList() {
        List<DemoDto> dtos = new ArrayList<DemoDto>();
        dtos.add(new DemoDto("tom", 123));
        dtos.add(new DemoDto("peter", 4546));
        demo.syncList(dtos);
    }

    @Test
    public void testSyncSet() {
        Set<DemoDto> dtos = new HashSet<DemoDto>();
        dtos.add(new DemoDto("tom", 123));
        dtos.add(new DemoDto("peter", 4546));
        demo.syncSet(dtos);
    }

    @Test
    public void testSyncMap() {
        Map<String, DemoDto> dtos = new HashMap<String, DemoDto>();
        dtos.put("tome", new DemoDto("tom", 123));
        dtos.put("peter", new DemoDto("peter", 4546));
        demo.syncMap(dtos);
    }

}
